<?php if(!defined('GbIncl2')){?>
<meta http-equiv="refresh" content="0;url=../spm-itats/block.php" />
<?php } else { ?>
	<?php
    $_GET['set']=isset($_GET['set']) ? $_GET['set'] :'';
	if ($_SESSION['JURUSAN']=='1'){ ?>
    <div class="section">
    <ul class="nice-list">
        <li>
            <table width="100%" border="2">
              <tr class="even">
                <td width="10%">ID JURUSAN</td>
                <td width="80%">NAMA JURUSAN</td>
                <td width="10%">PENGATURAN</td>
              </tr>
			  <?php $JJURUSAN=mysql_query("select * from JURUSAN_SPM ORDER BY ID_JURS ASC");
			  while ($DATAJJURUSAN=mysql_fetch_array($JJURUSAN)){?>
              <tr>
                <td><?php echo $DATAJJURUSAN['ID_JURS'] ?></td>
                <td><?php echo $DATAJJURUSAN['NAMA_JURS'] ?></td>
                <td>
                    <?php 
					$dlinkid=$DATAJJURUSAN['ID_JURS'];
					$elinkid=substr(md5($DATAJJURUSAN['ID_JURS']),8,8);
                    echo "<a href=?setting=jurusan&amp;id=$dlinkid&amp;set=02>";?>edit</a> | 
                    <?php echo "<a href=?setting=jurusan&amp;id=$dlinkid&amp;set=03>";?> delete</a>
                </td>
              </tr> 
			  <?php } ?>
              <tr>
                <td colspan="5"><?php echo "<a href=?setting=jurusan&amp;set=01>";?>tambah data</a></td>
              </tr>
            </table>
        </li>
        <?php //AKHIR TAMPIL TABEL MASING MASING//?>
        
        <?php //AWAL FORM INSERT//?>
        <?php 
        if ($_GET['set']=='01'){?>
        <form id="f_s_jurusan" name="f_s_jurusan" method="post" action="">
          <table width="100%" border="2">
            <tr>
              <th scope="row" width="20%"><label for="t_j_id">ID JURUSAN</label></th>
              <th width="80%"><input type="text" class="text" size="27" name="t_j_id" id="t_j_id" autofocus="autofocus"/></th>
            </tr>
            <tr>
              <th scope="row"><label for="t_j_nama">NAMA JURUSAN</label></th>
              <th><input type="text" class="text" size="27" name="t_j_nama" id="t_j_nama" /></th>
            </tr>
            <tr>
              <th scope="row">&nbsp;</th>
              <th class="left"><input type="submit" name="submit" id="b_j_insert" class="button" value="Tambah" /></th>
            </tr>
          </table>
        </form>
        <?php //AKHIR FORM INSERT//?>
        
        <?php //AWAL DELETE//?>
        <?php }else if ($_GET['set']=='03'){
			$id=$_GET['id'];
			$deletejurusan = "DELETE FROM JURUSAN_SPM WHERE ID_JURS='$id' LIMIT 1";
			$hasildeletejurusan = mysql_query($deletejurusan);
			if ($hasildeletejurusan){
				echo "<p>Proses Hapus Sukses .</p>";?>
				<meta http-equiv="refresh" content="0;url='../cpanel/?setting=jurusan'"><?php
			}else echo "<p>Proses Hapus Gagal</p>";?>
            <?php } ?>
        <?php //AKHIR DELETE//?>
                
        <?php //AWAL INSERT//?>
        <?php
		if ($_GET['set']=='01' and !empty($_POST['t_j_id']) and !empty($_POST['t_j_nama'])){
            $insertjurusan = "INSERT INTO JURUSAN_SPM VALUES ('$_POST[t_j_id]','$_POST[t_j_nama]')";
			$hasilinsertjurusan = mysql_query($insertjurusan);
            if ($hasilinsertjurusan){
                echo "<p>Proses Input Sukses .</p>";?>
                    <meta http-equiv="refresh" content="0;url='../cpanel/?setting=jurusan'">
            <?php }else echo "<p>Proses Input Gagal</p>";?>
        <?php }else if ($_GET['set']=='01' and empty($_POST['t_j_id']) and empty($_POST['t_j_nama'])) echo "Data tidak boleh kosong";?>
        <?php //AKHIR INSERT//?>	
    </ul>
    </div>
	<?php }else {?>
    	<meta http-equiv="refresh" content="0;url=block.php" />
    <?php }?>
<?php }?>

<?php
/*

*/
?>